package com.liusuai.yixian.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ResourceConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
        registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
        registry.addResourceHandler("/voices/**").addResourceLocations("classpath:/static/voices/");
        //上传的图片在D盘下的localdesk目录下，
        // 访问路径如：http://localhost:8011/yixian/localdesk/icon.jpg
        //其中localdesk表示访问的前缀。"file:D:/localdesk/"是文件真实的存储路径
        registry.addResourceHandler("/localdesk/**").addResourceLocations("file:D:/localdesk/");
    }

}
